package com.yiip.mr.etl.gulivideo;

public class ETLUtil {

    //清洗数据
    public static String etlStr(String oriStr) {
        //1、判断，数据长度是否小于9，过滤掉长度不符的数据
        String stringBuilder = "";
        String[] fields = oriStr.split("\t");
        if(fields.length<9){
            return null;
        }
        //2、将空格去掉。
        fields[3] = fields[3].replace(" ","");

        //3、按照\t重新组合。并且最后一个相关视频，用&连接。
        for (int i = 0;i<fields.length;i++) {
            if(i<9){
                if(i == fields.length -1){
                    stringBuilder += fields[i];
                }else{
                    stringBuilder += fields[i]+"\t";
                }
            }else{
                if(i == fields.length -1){
                    stringBuilder += fields[i];
                }else{
                    stringBuilder += fields[i]+"&";
                }
            }
        }
        return stringBuilder;
    }
}
